package utils;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by john on 2017/3/5.
 */
public class TimeUtil {
    public static String timeStampToString(Timestamp timestamp) {
        if (timestamp == null) {
            return "";
        }

        return timestamp.toString();
    }
    
    public static String mileageSelect(String mileage){
    	
    	if(mileage == null){
    		 return "";
    	}
    	
    	
		return mileage;
    	
    }
    
    public static String TimeSelect(String querytime,String productname ){
    	
    	if(querytime ==null && productname == null){
    		long d = System.currentTimeMillis();
    		
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
    		String querynow = sdf.format(d);
    		return querynow;
    	}
    	else{
    		 return "";
    	}
    	
    	
    }
    
    public static String LastDay(String querytime,String productname ){
    	
    	if(querytime ==null && productname == null){
    		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			Calendar calendar = Calendar.getInstance();
			int month = calendar.get(Calendar.MONTH);
			calendar.set(Calendar.MONTH, month - 1);
			calendar.set(Calendar.DAY_OF_MONTH,
					calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
			Date strDateTo = calendar.getTime();
			String lastDay = format.format(strDateTo);
			return lastDay;
    	}
    	else{
    		 return "";
    	}
    	
    	
    }
    
}

